package site.util;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class Collections {

    /**
     * 组合一组对象为Map, 偶数位对象为键, 奇数位对象为值.
     * @param objects 对象列表。
     * @return Map实例
     */
    public static Map asMap(Object... objects) {
        Map m = new HashMap(objects.length / 2 + 1);
        int i = 0;
        for (; i < objects.length - 1; i += 2) {
            m.put(objects[i], objects[i + 1]);
        }

        if (i < objects.length) {
            m.put(objects[i], null);
        }

        return m;
    }
}
